#ifndef _LOGIN_AUTHORITY_TASK_H_
#define _LOGIN_AUTHORITY_TASK_H_

#include "task.h"
#include <qbprotocol/include/rdProto.h>
#include <qbmessage/include/message_bond.h>
#include <set>
#include <memory>

namespace qb
{
    // 登录到LoginServer进行验证的任务
    class CLoginAuthorityTask
        : public CTask
        , public IQpidMessageProcessor
    {
    public:
        CLoginAuthorityTask();
        ~CLoginAuthorityTask();

        void RequestUserPermission();
        void RequestCDCAuthority();
        void RequestCSIAuthority();

	protected:
		virtual void StartImpl();
		virtual void TerminateImpl();
        virtual bool IsConnectTask() { return false; }
        virtual void OnNetData(char* pRecvData, int nDataLen) {}
        virtual void OnNetStatus(int32_t status) {}
        virtual int32_t GetTaskTimeout() { return LOGIN_AUTHORITY_TIMEOUT; }
        void OnTimeout() override;

        void AuthorityTaskFinish(_eFunID_t funcid);
        STDMETHOD_(void, OnResponse) (THIS_ int32_t funcId, const SSAckMsg&);

    private:
        std::set<_eFunID_t> m_setAuthority;
        std::shared_ptr<CLoginAuthorityTask>    m_ptr = nullptr;
    };
}

#endif
